
<template>
  <div class="app-container">
    <!-- 搜索表单 -->
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-loading="loading" label-width="100px">
      <el-form-item label="终端编号" prop="terminalNo">
        <el-input
          v-model="queryParams.terminalNo"
          placeholder="请输入终端编号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="用户编号" prop="phoneNo">
        <el-input
          v-model="queryParams.phoneNo"
          placeholder="请输入用户编号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="品牌名称" prop="smName">
        <el-input
          v-model="queryParams.smName"
          placeholder="请输入品牌名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="用户标签" prop="userLabel">
        <el-select v-model="queryParams.userLabel" placeholder="请选择用户标签">
          <el-option label="全部" value=""></el-option>
          <el-option label="新用户" value="新用户"></el-option>
          <el-option label="潜在流失用户" value="潜在流失用户"></el-option>
          <el-option label="一般用户" value="一般用户"></el-option>
          <el-option label="忠诚用户" value="忠诚用户"></el-option>
          <el-option label="高价值用户" value="高价值用户"></el-option>
        </el-select>
      </el-form-item>
        <el-form-item label="电视消费水平">
          <el-select v-model="queryParams.tvFeeLevel" placeholder="请选择电视消费水平">
            <el-option label="全部" value=""></el-option>
            <el-option label="低消费" value="低消费"></el-option>
            <el-option label="中消费" value="中消费"></el-option>
            <el-option label="高消费" value="高消费"></el-option>
            <el-option label="超高消费" value="超高消费"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="宽带消费水平">
          <el-select v-model="queryParams.broadbandFeeLevel" placeholder="请选择宽带消费水平">
            <el-option label="全部" value=""></el-option>
            <el-option label="低消费" value="低消费"></el-option>
            <el-option label="中消费" value="中消费"></el-option>
            <el-option label="高消费" value="高消费"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="用户是否挽留">
          <el-select v-model="queryParams.retentionStatus" placeholder="请选择用户是否挽留">
            <el-option label="全部" value=""></el-option>
            <el-option label="是" value="是"></el-option>
            <el-option label="否" value="否"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="业务品牌">
          <el-select v-model="queryParams.businessBrand" placeholder="请选择业务品牌">
            <el-option label="全部" value=""></el-option>
            <el-option label="品牌A" value="品牌A"></el-option>
            <el-option label="品牌B" value="品牌B"></el-option>
            <el-option label="品牌C" value="品牌C"></el-option>
            <el-option label="品牌D" value="品牌D"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="电视入网程度">
          <el-select v-model="queryParams.tvTenureLevel" placeholder="请选择电视入网程度">
            <el-option label="全部" value=""></el-option>
            <el-option label="新入网" value="新入网"></el-option>
            <el-option label="中期用户" value="中期用户"></el-option>
            <el-option label="长期用户" value="长期用户"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="宽带入网程度">
          <el-select v-model="queryParams.broadbandTenureLevel" placeholder="请选择宽带入网程度">
            <el-option label="全部" value=""></el-option>
            <el-option label="新入网" value="新入网"></el-option>
            <el-option label="中期用户" value="中期用户"></el-option>
            <el-option label="长期用户" value="长期用户"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="消费类型">
          <el-select v-model="queryParams.feeType" placeholder="请选择消费类型">
            <el-option label="全部" value=""></el-option>
            <el-option label="基础消费" value="基础消费"></el-option>
            <el-option label="增值消费" value="增值消费"></el-option>
            <el-option label="混合消费" value="混合消费"></el-option>
          </el-select>
        </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="small" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="small" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <!-- 表格 -->
    <el-table v-loading="loading" :data="userList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="终端编号" prop="terminalNo" align="center" />
      <el-table-column label="用户编号" prop="phoneNo" align="center" />
      <el-table-column label="品牌名称" prop="smName" align="center" />
      <el-table-column label="状态名称" prop="runName" align="center" />
      <el-table-column label="用户等级" prop="ownerName" align="center" />
      <el-table-column label="用户标签" prop="userLabel" align="center" />
      <el-table-column label="电视消费水平" prop="tvFeeLevel" align="center" />
      <el-table-column label="宽带消费水平" prop="broadbandFeeLevel" align="center" />
      <el-table-column label="用户是否挽留" prop="retentionStatus" align="center" />
      <el-table-column label="业务品牌" prop="businessBrand" align="center" />
      <el-table-column label="电视入网程度" prop="tvTenureLevel" align="center" />
      <el-table-column label="宽带入网程度" prop="broadbandTenureLevel" align="center" />
      <el-table-column label="消费类型" prop="feeType" align="center" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['media:user:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['media:user:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <!-- 分页 -->
    <el-pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :page-size.sync="queryParams.pageSize"
      :current-page="queryParams.pageNum"
      :page-sizes="[10, 20, 30, 50]"
      layout="total, sizes, prev, pager, next, jumper"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    />
  </div>
</template>

<script>
import { listUser, getUser, delUser, addUser, updateUser } from "@/api/media/user"

export default {
  name: "MediaUserList",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 总条数
      total: 0,
      // 用户列表
      userList: [],
      // 查询参数
        queryParams: {
        pageNum: 1,
        pageSize: 10,
        terminalNo: undefined,
        phoneNo: undefined,
        smName: undefined,
        userLabel: undefined,
        tvFeeLevel: undefined,
        broadbandFeeLevel: undefined,
        retentionStatus: undefined,
        businessBrand: undefined,
        tvTenureLevel: undefined,
        broadbandTenureLevel: undefined,
        feeType: undefined
        }
    }
  },
  created() {
    this.getList()
  },
  methods: {
    /** 查询用户列表 */
    getList() {
      this.loading = true
      listUser(this.queryParams).then(response => {
        this.userList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.$refs.queryForm.resetFields()
      this.handleQuery()
    },
    /** 多选框选中数据 */
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    }
  }
}
</script>
